package com.kun.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class ResourceConfig implements WebMvcConfigurer {

    @Value("${file.upload.blogPicturePath}")
    private String blogPicturePath;

    @Value("${file.download.sqlFilePrefix}")
    private String sqlFile;

    @Value("${file.captcha.captchaPicturePath}")
    private String captchaPicturePath;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {

        registry.addResourceHandler("/attach/download/captchaPicture/**")      //验证码图片
                .addResourceLocations("file:"+captchaPicturePath);
        registry.addResourceHandler("/attach/download/sql/sqlFile/**")      //sql文件
                .addResourceLocations("file:"+sqlFile);
        registry.addResourceHandler("/attach/download/*")      //博客图片
                .addResourceLocations("file:"+blogPicturePath);
    }
}
